#include"TCPClient.h"
#include <string.h>
const int SOCKETTIMEOUT=1200;
const int BUFFSIZE=1024;

int main()
{
	TCPClient tcpClient;
	const char *serIp="192.168.10.149"; //server ip
	int serPort=12345; //server port
	char buf[BUFFSIZE];
	char bufRev[BUFFSIZE];
	memset(buf,0,sizeof(buf));
	memset(bufRev,0,sizeof(bufRev));

	printf("input message:\n");
	scanf("%s",buf);
	if (strcmp(buf,"bye")==0)
	{
		printf("quit!\n");
		return 1;
	}

	if(tcpClient.connectToServer(serIp,serPort,SOCKETTIMEOUT))
	{
		if(0<tcpClient.sendData(buf,strlen(buf),SOCKETTIMEOUT))
		{
			while (1)
			{
				if (tcpClient.receiveAllData(bufRev,SOCKETTIMEOUT)>0)
				{
					printf("get: %s\n",bufRev);
					break;
				}
			}
		}
	}
	tcpClient.closeTcpSocket();
	return 0;
}
